home *** CD-ROM | disk | FTP | other *** search
/ Aminet 52 / Aminet 52 (2002)(GTI - Schatztruhe)[!][Dec 2002].iso / Aminet / util / moni / Sysmon120a.lha / sysmon / include / sysmon.h < prev    next >
C/C++ Source or Header  |  2002-03-10  |  16KB  |  375 lines

  1. /*
  2. **      $RCSfile: sysmon.h,v $
  3. **      $Filename: sysmon.h $
  4. **      $Revision: 1.16 $
  5. **      $Date: 2001/04/28 14:12:22 $
  6. **
  7. **    sysmon.library C header file (version 1.18)
  8. **    
  9. **    (C) Copyright 1995-2002 by Etienne Vogt
  10. */
  11.  
  12. #ifndef LIBRARIES_SYSMON_H
  13. #define LIBRARIES_SYSMON_H
  14.  
  15. #ifndef EXEC_LIBRARIES_H
  16. #include <exec/libraries.h>
  17. #endif
  18.  
  19. #ifndef EXEC_SEMAPHORES_H
  20. #include <exec/semaphores.h>
  21. #endif
  22.  
  23. #ifndef EXEC_MEMORY_H
  24. #include <exec/memory.h>
  25. #endif
  26.  
  27. #ifndef DEVICES_TIMER_H
  28. #include <devices/timer.h>
  29. #endif
  30.  
  31. #ifndef DOS_DATETIME_H
  32. #include <dos/datetime.h>
  33. #endif
  34.  
  35. /* Library data structure
  36. ** All field in the SysmonBase structure are PRIVATE !!!
  37. ** Don't access these directly as they will change in future versions.
  38. ** You have been warned !!!
  39. */
  40.  
  41. #define    HASHSIZE    32
  42. #define HASHMASK    0xf8
  43.  
  44. struct SysmonBase
  45. {    struct Library sb_Lib;            /* Standard lib node */
  46.     UBYTE    sb_Flags;            /* Some flags here */
  47.     UBYTE    sb_pad;                /* We are now longword aligned */
  48.     struct ExecBase *sb_ExecBase;        /* Pointer to exec */
  49.     struct Library *sb_UtilityBase;        /* Pointer to utility */
  50.     BPTR    sb_SegList;            /* SegList BCPL pointer */
  51.     struct TaskInfo *sb_CurrTaskInfo;    /* Current TaskInfo Structure */
  52.     APTR    sb_Switch;            /* Original Switch() entry point */
  53.     APTR    sb_Dispatch;            /* Original Dispatch() entry point */
  54.     APTR    sb_AddTask;            /* Original AddTask() entry point */
  55.     APTR    sb_RemTask;            /* Original RemTask() entry point */
  56.     APTR    sb_FindTask;            /* Original FindTask() entry point */
  57.     APTR    sb_Alert;            /* Original Alert() entry point */
  58.     APTR    sb_ExitIntr;             /* Original ExitIntr() entry point */
  59.     APTR    sb_Schedule;             /* Original Schedule() entry point */
  60.     APTR    sb_Exception;             /* Original Exception() entry point */
  61.     APTR    sb_SetTaskPri;             /* Original SetTaskPri() entry point */
  62.     APTR    sb_SetExcept;             /* Original SetExcept() entry point */
  63.     APTR    sb_SetSignal;             /* Original SetSignal() entry point */
  64.     APTR    sb_Signal;             /* Original Signal() entry point */
  65.     APTR    sb_Wait;            /* Original Wait() entry point */
  66.     APTR    sb_TaskExit;            /* Original ExecBase->TaskExitCode */
  67.     APTR    sb_TaskExcept;            /* Original ExecBase->TaskExceptCode */
  68.     APTR    sb_TaskTrap;            /* Original ExecBase->TaskTrapCode */
  69.     struct timerequest sb_TimeReq;        /* Time Request */
  70.     struct EClockVal sb_TempTime;        /* Temporary EClock Time */
  71.     struct List sb_TaskFrozen;        /* List of frozen tasks */
  72.     BYTE    sb_ResetBit;            /* Signal bit for reset handler */
  73.     UBYTE    sb_ResetFlags;            /* Flags for reset handler */
  74.     struct TaskInfo *sb_TaskInfoHash[HASHSIZE]; /* TaskInfo hash table */
  75.     APTR    sb_ServerEntry;            /* Server process entry point */
  76.     STRPTR    sb_ServerName;            /* Server process name */
  77.     STRPTR    sb_SyslogFile;            /* SysLog file name */
  78.     STRPTR    sb_SyslogWindow;        /* Syslog Window Name */
  79.     UBYTE    sb_FilePri;            /* File logging priority */
  80.     UBYTE    sb_WindowPri;            /* Window logging priority */
  81.     UBYTE    sb_ConsolePri;            /* Console logging priority */
  82.     UBYTE    sb_NumLogBuffers;        /* Number of allocated Buffers */
  83.     struct SysLogMsg *sb_Buffers;        /* Pointer to allocated buffers */
  84.     struct DosLibrary *sb_DOSBase;        /* Pointer to dos */
  85.     struct DateTime    *sb_DateTime;        /* SysLog DateTime structure */
  86.     ULONG    sb_StampPeriod;            /* Period for syslog file stamp */
  87.     BPTR    sb_LogWindowHandle;        /* LogWindow file handle */
  88.     struct Library *sb_IntuitionBase;    /* Pointer to intuition */
  89.     struct LastGuru    *sb_LastGuru;        /* Pointer to LastGuru structure */
  90.     struct MsgPort *sb_SyslogPort;        /* Pointer to Syslog MsgPort */
  91.     struct Process *sb_ServerProc;        /* Pointer to server process */
  92.     struct Interrupt *sb_ResetHandler;    /* Pointer to reset handler */
  93.     struct IOStdReq *sb_ResetReq;        /* Pointer to reset request */
  94.     struct SignalSemaphore sb_BCPSem;    /* Semaphore for Broadcast Ports list */
  95.     struct MinList sb_BroadcastPorts;    /* List of Registered Broadcast Ports */
  96.     struct SignalSemaphore sb_TTASem;    /* Semaphore for Task Table Access */
  97.     struct SignalSemaphore sb_TTRSem;    /* Semaphore for Task Table Removal */
  98.     struct EClockVal sb_CPUTime;        /* Total CPU Time used by tasks */
  99.     struct Library *sb_MMUBase;        /* Pointer to mmu library */
  100.     APTR    sb_ColdReboot;            /* Cached ColdReboot() vector */
  101.     ULONG    sb_VolTSw;            /* Voluntary Task Switches counter */
  102.     ULONG    sb_InvTSw;            /* Involuntary Task Switches counter */
  103.     struct Interrupt sb_LdAvrVBLInt;    /* Load Average VBL Interrupt */
  104.     UWORD    sb_LdAvrPtr;            /* Pointer in Load Average circular buffer */
  105.     UBYTE    sb_LdAvrBuffer[15*60];        /* Load Average circular Buffer, updated every
  106.                            second from the sysmon.library VBlank interrupt */
  107.     ULONG    sb_QuantumExp;            /* Global Quantum Expiration counter */
  108.     APTR    sb_SuperState;            /* Original SuperState() entry point */
  109.     APTR    sb_UserState;            /* Original UserState() entry point */
  110. };
  111.  
  112. /* The TaskInfo structure contains the CPU usage information in EClock ticks.
  113. ** The link pointers are private and should not be used. Use the smNextTaskInfo()
  114. ** function to traverse the list.
  115. ** This structure may be extended later with new fields. Also all fields are
  116. ** strictly READ ONLY.
  117. */
  118.  
  119. struct TaskInfo
  120. {    struct TaskInfo *ti_Link;        /* PRIVATE pointer to next TaskInfo */
  121.     struct TaskInfo *ti_Pred;        /* PRIVATE pointer to previous TaskInfo    */
  122.     struct Task *ti_Task;            /* pointer to Task Control Block */
  123.     ULONG    ti_DispCount;            /* Task Dispatch counter */
  124.     struct EClockVal ti_StartTime;        /* Starting EClock Time    */
  125.     struct EClockVal ti_LaunchTime;        /* Last Launch Time */
  126.     struct EClockVal ti_CPUTime;        /* Cumulated CPU Time */
  127.     UBYTE    ti_Flags;            /* Various flags */
  128.     UBYTE    ti_ExcptState;            /* Task State saved by Exception() */
  129.     BYTE    ti_EDNestCnt;            /* Exception Disable Nest Count */
  130.     UBYTE    ti_FreezeState;            /* Task State saved by smFreeze() */
  131.     ULONG    ti_VolTSw;            /* Voluntary Task Switches counter */
  132.     ULONG    ti_InvTSw;            /* Involuntary Task Switches counter */
  133.     ULONG    ti_QuantumExp;            /* Quantum Expiration counter */
  134. };
  135.  
  136. /* ti_Flags bits */
  137.  
  138. #define    TIB_INEXCEPT    0            /* Task is inside Exception code */
  139. #define    TIF_INEXCEPT    (1L << 0)
  140. #define    TIB_WAKEUP    1            /* A WakeUp request is pending */
  141. #define TIF_WAKEUP    (1L << 1)
  142.  
  143. /* This is the private structure used by smVSysLog() to communicate with the
  144. ** Sysmon.server process.
  145. */
  146.  
  147. #define    SM_MAXLOGCHARS    256            /* Max bytes in SysLog message    */
  148.  
  149. struct    SysLogMsg
  150. {    struct Message    slm_MsgHead;        /* Message header    */
  151.     ULONG    slm_Priority;            /* SysLog priority and flags    */
  152.     UBYTE    slm_Text[SM_MAXLOGCHARS];    /* Syslog Message body    */
  153. };
  154.  
  155. #define    SYSMONNAME    "sysmon.library"
  156. #define    SERVERNAME    "Sysmon.server"
  157.  
  158. /* Definition of sb_Flags bits    */
  159.  
  160. #define SBFB_FPU    0            /* System has a FPU */
  161. #define    SBFF_FPU    (1L << 0)
  162. #define    SBFB_IDLELED    1            /* Dim power LED when CPU is idle */
  163. #define    SBFF_IDLELED    (1L << 1)
  164. #define SBFB_MMU    2            /* System has a MMU (according to mmu.library) */
  165. #define SBFF_MMU    (1L << 2)
  166. #define SBFB_MACOSKLUDGE 3            /* Try to be friendly to MacOS emulators */
  167. #define SBFF_MACOSKLUDGE (1L << 3)
  168. #define    SBFB_SUPERSTATE    7            /* PRIVATE flag for smSuperState() */
  169. #define    SBFF_SUPERSTATE    (1L << 7)
  170.  
  171. /* Definition of sb_ResetFlags bits */
  172.  
  173. #define    SBRSTB_ACTIVATE    0            /* Activate reset handler */
  174. #define    SBRSTF_ACTIVATE    (1L << 0)
  175. #define    SBRSTB_PENDING    1            /* Reset is pending */
  176. #define SBRSTF_PENDING    (1L << 1)
  177. #define    SBRSTB_OLDMMU    2            /* Restore old MMU setup before reboot */
  178. #define    SBRSTF_OLDMMU    (1L << 2)
  179. #define SBRSTB_CACHEREBOOT    3        /* Use a cached ColdReboot() vector */
  180. #define SBRSTF_CACHEREBOOT    (1L << 3)
  181.  
  182. /* Alert Definitions
  183. ** These are the Guru codes that sysmon.library can spit out in a panic
  184. ** condition.
  185. */
  186.  
  187. #define    AN_Sysmon    0x40000000        /* SubSystem ID    */
  188. #define    AN_smNoTaskInfo    0x40000001        /* No TaskInfo structure for this task */
  189. #define    AN_smNoTIMem    0x40010002        /* No mem for TaskInfo at startup    */
  190. #define    AN_smSysLogBuf    0x40010003        /* No memory for syslog buffers    */
  191. #define    AN_BadSysLogMsg    0x40000004        /* Bad SysLogMsg received by server */
  192. #define    AN_smNoLastGuru    0x40010005        /* No memory for LastGuru buffer */
  193. #define    AN_smNoAlertMem    0x40010006        /* No memory for new alert.hook module */
  194. #define    AN_smSuperTaskSwitch 0xC0000007        /* Attempt to switch task from supervisor mode */
  195. #define AN_smInconSchedState 0xC0000008        /* Inconsistant Scheduling State */
  196. #define AO_Sysmon    0x00008040        /* Alert object    */
  197.  
  198. /* These are reused obsolete exec alert codes */
  199.  
  200. #define    AN_UnInitExcpt    0x0100000A        /* Uninitialized task exception (not CPU trap) */
  201.  
  202. /* New Task States Definitions
  203. ** TS_STOP is not a real state. It is used by ShowSys to identify tasks that
  204. ** are stuck in a Wait(0) call, such as crashed tasks that have been suspended.
  205. */
  206.  
  207. #define    TS_STOP        0x80            /* Stopped task (Wait(0L)) */
  208. #define    TS_FROZEN    0x81            /* Frozen task */
  209. #define    TS_HIBERNATE    0x82            /* Hibernating task */
  210. #define    TS_PAGEFLTWAIT    0x83            /* Task suspended for page fault processing */
  211. #define    TS_WAITAND    0x84            /* Task waiting for several signals set together */
  212. #define    TS_TRAP        0x85            /* Task suspended by exception trap code */
  213. #define    TS_FREEWAIT    0x86            /* Task waiting for free memory */
  214.  
  215. /* SysLog Priorities, facilities and flags
  216. ** The priorities are similar to that used on UNIX systems. This means that
  217. ** the values use the UNIX ordering that is reversed from the Amiga one.
  218. ** The facilities are also UNIX like and indicate what part of the system
  219. ** produced the message. This is purely informational currently.
  220. ** The flags are Amiga and sysmon specifics.
  221. */
  222.  
  223. /* Priorities */
  224.  
  225. #define    LOG_EMERG    0            /* Panic condition (Guru time)    */
  226. #define    LOG_ALERT    1            /* Very serious problem    */
  227. #define LOG_CRIT    2            /* Critical error    */
  228. #define    LOG_ERR        3            /* General error condition    */
  229. #define    LOG_WARN    4            /* Warning condition    */
  230. #define    LOG_NOTICE    5            /* Noticeable event    */
  231. #define    LOG_INFO    6            /* General informational event    */
  232. #define    LOG_DEBUG    7            /* Debugging information    */
  233. #define    LOG_PRI        0x07            /* Mask for priority field    */
  234.  
  235. /* Facilities */
  236.  
  237. #define    LOG_NOFAC    (0<<3)            /* no facility */
  238. #define    LOG_KERN    (1<<3)            /* kernel/system messages */
  239. #define    LOG_USER    (2<<3)            /* random user-level messages */
  240. #define    LOG_MAIL    (3<<3)            /* mail system */
  241. #define    LOG_DAEMON    (4<<3)            /* system daemons/commodities */
  242. #define    LOG_AUTH    (5<<3)            /* security/authorization messages */
  243. #define    LOG_SYSLOG    (6<<3)            /* messages generated internally by Syslog */
  244. #define    LOG_NEWS    (7<<3)            /* network news subsystem */
  245. #define    LOG_UUCP    (8<<3)            /* UUCP subsystem */
  246. #define    LOG_CRON    (9<<3)            /* cron/queue_manager subsystem */
  247. #define    LOG_AUTHPRIV    (10<<3)            /* private security/authorization messages */
  248. #define    LOG_FTP        (11<<3)            /* ftp daemon */
  249. /* other codes through 15 reserved for system use */
  250. #define    LOG_LOCAL0    (16<<3)            /* reserved for local use */
  251. #define    LOG_LOCAL1    (17<<3)            /* reserved for local use */
  252. #define    LOG_LOCAL2    (18<<3)            /* reserved for local use */
  253. #define    LOG_LOCAL3    (19<<3)            /* reserved for local use */
  254. #define    LOG_LOCAL4    (20<<3)            /* reserved for local use */
  255. #define    LOG_LOCAL5    (21<<3)            /* reserved for local use */
  256. #define    LOG_LOCAL6    (22<<3)            /* reserved for local use */
  257. #define    LOG_LOCAL7    (23<<3)            /* reserved for local use */
  258. #define    LOG_MARK    (24<<3)            /* special time stamp mark */
  259. #define LOG_UNKNOWN    (25<<3)            /* unknown facility code */
  260. #define    LOG_FAC        0x03f8            /* Mask for facility field */
  261.  
  262. /* Flags */
  263.  
  264. #define    LOG_INUSE    0x80000000        /* Message is in use (private !) */
  265. #define    LOG_NOHEAD    0x40000000        /* Don't prepend header    */
  266. #define    LOG_NOWIN    0x20000000        /* Don't output to window    */
  267. #define    LOG_NOFILE    0x10000000        /* Don't output to file    */
  268.  
  269. #define    LOGB_INUSE    31            /* Bit numbers for flags    */
  270. #define    LOGB_NOHEAD    30
  271. #define    LOGB_NOWIN    29
  272. #define    LOGB_NOFILE    28
  273.  
  274.  
  275. /* Flags definitions for smHalt()    */
  276.  
  277. #define    HALTB_REBOOT    0        /* Reboot immediately    */
  278. #define    HALTF_REBOOT    (1L << 0)
  279. #define    HALTB_REKICK    1        /* Reload kickstart on MMU-Kicked systems.    */
  280. #define    HALTF_REKICK    (1L << 1)
  281.  
  282. /* Broadcast Message send via smSendBroadcastMsg()
  283. ** The sender must allocate this structure and fill in the different fields.
  284. */
  285.  
  286. struct BroadcastMsg
  287. {    struct Message bcm_Msg;            /* Standard Message structure */
  288.     UBYTE    bcm_Level;            /* Event Level */
  289.     UBYTE    bcm_Flags;            /* Flags */
  290.     UWORD    bcm_TimeOut;            /* Reply Time Out in ticks */
  291.     UWORD    bcm_CountDown;            /* Countdown to Event in seconds */
  292.     UBYTE    bcm_ReplyCount;            /* Reply count after sending */
  293.     UBYTE    bcm_TimeOutCount;        /* Time Out count after sending */
  294.     struct Task *bcm_SenderTask;        /* Sender Task (Filled by smSendBroadcastMsg()) */
  295.     STRPTR    bcm_EventTxt;            /* Text describing the event */
  296.     ULONG    bcm_Reserved[4];        /* Reserved for future expansion */
  297. };
  298.  
  299. /* defines for event levels */
  300.  
  301. #define    BCM_HALT    0        /* System Halt/Reboot imminent */
  302. #define    BCM_UNMOUNT    1        /* FileSystems will be UnMounted now */
  303. #define    BCM_SHUTDOWN    2        /* Shutdown countdown message */
  304. #define    BCM_URGENT    3        /* Urgent Message */
  305. #define    BCM_NORMAL    4        /* Normal Message */
  306. #define    BCM_DEBUG    5        /* Debug Level Message */
  307.  
  308. /* defines for bcm_Flags */
  309.  
  310. #define    BCMB_DOOMSDAY    0        /* Keyboard reset pending */
  311. #define    BCMF_DOOMSDAY    (1L << 0)    /*  (System reboot in 10 seconds at most) */
  312. #define    BCMB_CANCEL    1        /* A previously announced event has been cancelled */
  313. #define    BCMF_CANCEL    (1L << 1)
  314.  
  315. /* defines for smLockTaskTable()/smUnLockTaskTable() flags */
  316.  
  317. #define    LTTB_READ    0        /* Read access to task table */
  318. #define    LTTF_READ    (1L << 0)
  319. #define    LTTB_WRITE    1        /* Write access (PRIVATE !) */
  320. #define    LTTF_WRITE    (1L << 1)
  321. #define    LTTB_REMOVE    2        /* Prevent task removal */
  322. #define    LTTF_REMOVE    (1L << 2)
  323.  
  324. /* The LastGuru structure contains information about the last Guru Meditation
  325. ** The data is stored in a high memory buffer by Alert() that is allocated by
  326. ** sysmon.library during initialisation.
  327. ** As this buffer is allocated early with AllocMem(MEMF_REVERSE), it will be
  328. ** kept at the same address after reboot. This trick was already used successfully
  329. ** on recoverable ram disks like vdisk.device
  330. ** Some Fields are only valid if the corresponding register exists on the CPU
  331. ** installed in the system.
  332. */
  333.  
  334. struct LastGuru
  335. {    struct MemChunk lg_MC;        /* leave space for a memory chunk */
  336.     ULONG    lg_Sig;            /* Alert signature ('HELP') */
  337.     ULONG    lg_AlertNum;        /* Guru Meditation number */
  338.     ULONG    lg_AlertAddr;        /* TCB Address of crashed task */
  339.     UBYTE    lg_TaskName[32];    /* Task name limited to 32 bytes */
  340.     ULONG    lg_DataRegs[8];        /* Data registers D0-D7 */
  341.     ULONG    lg_AddrRegs[8];        /* Address registers A0-A7 */
  342.     ULONG    lg_FloatRegs[3*8];    /* Floating point registers FP0-FP7 */
  343.     ULONG    lg_FPCR;        /* Floating Point Control Register */
  344.     ULONG    lg_FPSR;        /* Floating Point Status Register */
  345.     ULONG    lg_FPIAR;        /* Floating Point Instruction Address Register */
  346.     ULONG    lg_PC;            /* Program Counter */
  347.     ULONG    lg_USP;            /* User Stack Pointer */
  348.     ULONG    lg_SSP;            /* Supervisor/Interrupt Stack Pointer */
  349.     ULONG    lg_MSP;            /* Master Stack Pointer / Processor Control Register [68060] */
  350.     ULONG    lg_VBR;            /* Vector Base Register */
  351.     ULONG    lg_SFC;            /* Source Function Codes */
  352.     ULONG    lg_DFC;            /* Destination Function Codes */
  353.     ULONG    lg_CACR;        /* Cache Control Register */
  354.     ULONG    lg_TC;            /* Translation Control register */
  355.     ULONG    lg_ITT0;        /* Intruction Transparent Translation 0 */
  356.     ULONG    lg_ITT1;        /* Intruction Transparent Translation 1 */
  357.     ULONG    lg_DTT0;        /* Data Transparent Translation 0 / Common Root Pointer [68030] */
  358.     ULONG    lg_DTT1;        /* Data Transparent Translation 1 / Common Root Pointer [68030] */
  359.     ULONG    lg_URP;            /* User Root Pointer / Supervisor Root Pointer [68030] */
  360.     ULONG    lg_SRP;            /* Supervisor Root Pointer */
  361.     ULONG    lg_MMUSR;        /* MMU Status Register / Bus Control Register [68060] */
  362.     ULONG    lg_CAAR;        /* Cache Address Register */
  363.     UWORD    lg_SR;            /* Status Register */
  364.     UWORD    lg_AC;            /* Access Control register [68851] */
  365.     ULONG    lg_DRP[2];        /* DMA Root Pointer [68851] */
  366.     UWORD    lg_BAD[8];        /* Breakpoint Acknowledge Data registers [68851] */
  367.     UWORD    lg_BAC[8];        /* Breakpoint Acknowledge Control registers [68851] */
  368.     UBYTE    lg_CAL;            /* Current Access Level [68851] */
  369.     UBYTE    lg_VAL;            /* Valid Access Level [68851] */
  370.     UBYTE    lg_SCC;            /* Stack Change Control register [68851] */
  371.     UBYTE    lg_Pad;            /* Padding byte */
  372. };
  373.  
  374. #endif  /* LIBRARIES_SYSMON_H */
  375.